package com.dave.protocol.exception;


import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;

/**
 * @PageName com.dave.common.exception
 * @Description 自定义exception
 * @Author 何全裕
 * @Create 2017-08-01 22:34
 * @Version 1.0
 **/
public class MallException implements HandlerExceptionResolver{

    @Override
    public ModelAndView resolveException(javax.servlet.http.HttpServletRequest httpServletRequest,
                                         javax.servlet.http.HttpServletResponse httpServletResponse,
                                         Object o, Exception ex) {
        Map<String,Object> model = new HashMap<String,Object>();
        model.put("ex",ex);

        // 根据不同错误转向不同页面
        /*if(ex instanceof BusinessException) {
            return new ModelAndView("error-business", model);
        }else if(ex instanceof ParameterException) {
            return new ModelAndView("error-parameter", model);
        } else {
            return new ModelAndView("error", model);
        }*/
        return new ModelAndView("error", model);
    }
}
